Option Public
Option Declare
%REM
Agent DOO_Crash
Created Jan 29, 2011 by e_bdetar
Description: Agent to cause server crash
%END REM
Sub Initialize()
Call crash()
End Sub
%REM
Function getDB
Description: Return an error
Return : NotesDatabase
%END REM
Function getDB As NotesDatabase
On Error GoTo handleError
Dim rc As NotesDatabase
Error 1000, "test crash"
GoTo handleExit
handleError:
On Error Resume Next
handleExit:
Set getDB = rc
End Function
%REM
Property Get DB
Description: Singleton to retrieve a notesdatabase
%END REM
Static Property Get DB As NotesDatabase
On Error GoTo handleError
Static singleton As Variant
If IsEmpty(singleton) Then
Set singleton = getDB()
End If
GoTo handleExit
handleError:
On Error Resume Next
handleExit:
Set DB = singleton
End Property
%REM
Sub crash
Description: Command used to crash a server or a client
%END REM
Sub Crash()
On Error GoTo handleError
MsgBox DB().Title
GoTo handleExit
handleError:
On Error Resume Next
handleExit:
End Sub
A way to prevent crash is to bypass getDB error handling.
%REM
Function getDB
Description: Return an error
Return : NotesDatabase
%END REM
Function getDB As NotesDatabase
On Error GoTo handleError
Dim rc As NotesDatabase
Error 1000, "test crash"
GoTo handleExit
handleError:
On Error Resume Next
resume handleExit
handleExit:
Set getDB = rc
End Function
But it isn't a valid solution.
In this case we lose all error handling.
Moreover all functions behavior depends on what is the calling proc.